/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * IngresoSistema.java
 *
 * Created on 25/10/2010, 10:16:15 PM
 */
package relojbiometrico;

import java.awt.event.KeyEvent;
import java.util.ArrayList;
import java.util.List;
import javax.swing.ImageIcon;
import javax.swing.JOptionPane;
import javax.swing.UIManager;

/**
 *
 * @author Dianita
 */
public class IngresoSistema extends javax.swing.JFrame {

    /** Creates new form IngresoSistema */
    public IngresoSistema() {
        initComponents();
        txtUsuario.requestFocusInWindow();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        imagePanel1 = new com.mycsistemas.swingec.panel.ImagePanel();
        curvesPanel1 = new com.mycsistemas.swingec.panel.CurvesPanel();
        txtUsuario = new javax.swing.JTextField();
        btnSalir = new javax.swing.JButton();
        btnIngresar = new javax.swing.JButton();
        jLabel19 = new javax.swing.JLabel();
        jLabel20 = new javax.swing.JLabel();
        jLabel21 = new javax.swing.JLabel();
        txtContraseña = new javax.swing.JPasswordField();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("Sistema de Recursos Humanos");
        setMinimumSize(new java.awt.Dimension(420, 320));
        setResizable(false);
        getContentPane().setLayout(null);

        imagePanel1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/reloj/recursos/Bello Verde_800.jpg"))); // NOI18N
        imagePanel1.setLayout(null);

        curvesPanel1.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
        curvesPanel1.setLayout(null);

        txtUsuario.setFont(new java.awt.Font("Segoe Print", 1, 14));
        txtUsuario.setToolTipText("Ingrese el nombre del Usuario");
        txtUsuario.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent evt) {
                txtUsuarioKeyReleased(evt);
            }
        });
        curvesPanel1.add(txtUsuario);
        txtUsuario.setBounds(60, 100, 290, 30);

        btnSalir.setIcon(new javax.swing.ImageIcon(getClass().getResource("/reloj/recursos/DeleteRed.png"))); // NOI18N
        btnSalir.setText("SALIR");
        btnSalir.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnSalirActionPerformed(evt);
            }
        });
        curvesPanel1.add(btnSalir);
        btnSalir.setBounds(210, 220, 130, 40);

        btnIngresar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/reloj/recursos/tick_32.png"))); // NOI18N
        btnIngresar.setText("INGRESAR");
        btnIngresar.setToolTipText("Para ingresar Identifíquese");
        btnIngresar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnIngresarActionPerformed(evt);
            }
        });
        curvesPanel1.add(btnIngresar);
        btnIngresar.setBounds(70, 220, 130, 40);

        jLabel19.setFont(new java.awt.Font("Elephant", 0, 14));
        jLabel19.setText("Contraseña:");
        curvesPanel1.add(jLabel19);
        jLabel19.setBounds(70, 130, 110, 30);

        jLabel20.setFont(new java.awt.Font("Elephant", 0, 14));
        jLabel20.setText("- INGRESO AL SISTEMA -");
        curvesPanel1.add(jLabel20);
        jLabel20.setBounds(110, 20, 220, 40);

        jLabel21.setFont(new java.awt.Font("Elephant", 0, 14));
        jLabel21.setText("Usuario:");
        curvesPanel1.add(jLabel21);
        jLabel21.setBounds(70, 60, 110, 30);

        txtContraseña.setFont(new java.awt.Font("Segoe UI", 1, 14));
        txtContraseña.setToolTipText("Ingrese la Contraseña");
        txtContraseña.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                txtContraseñaKeyPressed(evt);
            }
        });
        curvesPanel1.add(txtContraseña);
        txtContraseña.setBounds(60, 170, 290, 30);

        imagePanel1.add(curvesPanel1);
        curvesPanel1.setBounds(0, 0, 430, 290);

        getContentPane().add(imagePanel1);
        imagePanel1.setBounds(0, 0, 430, 300);

        pack();
    }// </editor-fold>//GEN-END:initComponents

    
    private void btnIngresarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnIngresarActionPerformed
        // TODO add your handling code here:

        if (txtUsuario.getText().length() != 0) {
            if (txtContraseña.getText().length() != 0) {
                if(txtUsuario.getText().equals("Diana")&&txtContraseña.getText().equals("Diana")){
                    this.dispose();
                    Principal p = new Principal(this, true);
                    p.setLocationRelativeTo(this);
                    p.setVisible(true);                    
                }
            } else {
                // JOptionPane.showMessageDialog(this, "     Ingrese su contraseña", "Usuario", 1, new ImageIcon(getClass().getResource("/comil/recursos/User1.png")));
                txtContraseña.requestFocus();
            }

        } else {
            //JOptionPane.showMessageDialog(this, "   Ingrese su Nick de Usuario", "Usuario", 1, new ImageIcon(getClass().getResource("/comil/recursos/User1.png")));
            txtUsuario.requestFocus();
        }

}//GEN-LAST:event_btnIngresarActionPerformed

    private void btnSalirActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnSalirActionPerformed
        // TODO add your handling code here:
        System.exit(0);
}//GEN-LAST:event_btnSalirActionPerformed

    private void txtUsuarioKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtUsuarioKeyReleased
        // TODO add your handling code here:
        if (evt.getKeyCode() == KeyEvent.VK_ENTER) {
            btnIngresar.requestFocus();
            btnIngresarActionPerformed(null);
            //txtUsuario.requestFocus();
        }
    }//GEN-LAST:event_txtUsuarioKeyReleased

    private void txtContraseñaKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtContraseñaKeyPressed
        // TODO add your handling code here:
        if (evt.getKeyCode() == KeyEvent.VK_ENTER) {
            btnIngresar.requestFocus();
            btnIngresarActionPerformed(null);
        }
    }//GEN-LAST:event_txtContraseñaKeyPressed

    /**
     * @param args the command line arguments
     */
//    public static void main(String args[]) {
//        java.awt.EventQueue.invokeLater(new Runnable() {
//
//            public void run() {
//                new IngresoSistema().setVisible(true);
//
//
//
//            }
//        });
//
//
//
//
//    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btnIngresar;
    private javax.swing.JButton btnSalir;
    private com.mycsistemas.swingec.panel.CurvesPanel curvesPanel1;
    private com.mycsistemas.swingec.panel.ImagePanel imagePanel1;
    private javax.swing.JLabel jLabel19;
    private javax.swing.JLabel jLabel20;
    private javax.swing.JLabel jLabel21;
    private javax.swing.JPasswordField txtContraseña;
    private javax.swing.JTextField txtUsuario;
    // End of variables declaration//GEN-END:variables
}
